<template>
  <div>
    <button @click="creatQrCode('1908NetA')">查看二维码</button>
    <div class="qrcode divqr" ref="qrCodeUrl"></div>
  </div>
</template>

<script>

//npm引用： npm install --save qrcodejs2

//引入jquery
import $ from "jquery";

import QRCode from "qrcodejs2";

export default {
  methods: {
    creatQrCode(tmpVal) {
      $(".qrcode").html("");

      new QRCode(this.$refs.qrCodeUrl, {
        text: tmpVal, // 需要转换为二维码的内容
        width: 260,
        height: 260,
        colorDark: "#000000",
        colorLight: "#ffffff",
        correctLevel: QRCode.CorrectLevel.H,
      });
    },
  },
  mounted() {
    this.creatQrCode("天下风云出我辈");
  },
};
</script>

<style scoped>
.divqr {
  margin: 100px 0 0 600px;
}
</style>